package gui;

import java.awt.Font;
import java.util.ArrayList;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
//BrowseNotice类用于显示当前景区的公告，便于游客查看景区公告
public class BrowseNotice extends JFrame {
	private JPanel browseNoticePanel;

	public BrowseNotice() {
		super("景区通知通告");
		setSize(800, 600);
		setLocation(500, 200);

		Font font = new Font("宋体", Font.PLAIN, 25);
		UIManager.put("OptionPane.font", font);
		UIManager.put("OptionPane.messageFont", font);
		UIManager.put("OptionPane.buttonFont", font);

		setVisible(true);
	}
	
	public void browseNoticePanel() {
		browseNoticePanel = new JPanel();
		browseNoticePanel.setLayout(null);
		
        function.Notice notice=new function.Notice();
        //通过调用Notice类的getAll方法将公告相关内容存储在list中
        ArrayList<String> list = notice.getAll();
        //循环打印每条公告
		for (int i = 0; i < list.size(); i++) {
			JLabel informationLabel = new JLabel(list.get(i));
			informationLabel.setBounds(50, 50+100*i, 500, 80);
			informationLabel.setFont(new Font("宋体", Font.PLAIN, 25));
			browseNoticePanel.add(informationLabel);
		}
		
		browseNoticePanel.setVisible(true);
		add(browseNoticePanel);
		setVisible(true);
	}
}
